import httpRequest from '@/http/request'
import { number } from 'echarts'
import { reactive, ref,onUnmounted, onUpdated, onMounted, toRefs, } from 'vue'

// 定义接口的传参
interface addFishBaiKe {
    author:string,
    fishImg:string,
    fishName:string,
    introduction:string
}
interface addFishBaiKePic {
    pic:File,
}

// 分页的参数类型
interface page{
    current:number   //当前页
    body:{
        fishQuery:{
            author: string,
            fishName: string,
            introduction: string,
            timeBegin: string,
            timeEnd: string
          }
        
    }
    size:number
}
//鱼类返回图片路径
interface fishName{
    fishName:string
}

export interface bookBaiKeResData {
    total:number,
    maxPages:number,
    rows:Array<row>
   
}
export interface row {
    id:string,
    fishName:string,
    introduction:string,
    author:string
    fishImg:string
}


export function ApiGetFishBook(current:number,size:number){//传过来两个值分别是当前页数和条数
    // 拿到当前页和页数
    return httpRequest.post(`/web/fishbaike/getFishBaiKe/${current}/${size}`)
}
// export function ApiGetFishPath(fishName){//传过来鱼的名字
//     // 拿到当前页和页数
//     return httpRequest.get(`/web/fishbaike/getAllFishPic/${fishName}`)
// }


// 拿到所有鱼的图片
export function ApiFishImg(fishName:string){
    return httpRequest.get(`/web/fishbaike/getAllFishPic/${fishName}`)
}

export function apiFish(fishName: string,data:any) {
    console.log(data);
    
    let flag = false
    httpRequest({
    url: `/web/fishbaike/uploadDetailFishPic/${fishName}`,
    method: 'post',
    //设置请求头
    // headers: {
    // 'Content-Type': 'multipart/form-data'
    // },
    data
}).then(async (res) => {
    if (res.data.code != 0) {//成功
        flag=true
        return flag
    }
    console.log(res)
})
return false}




